home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / FileTransfers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  15.5 KB  |  373 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        FileTransfers.h
  3.  
  4.      Contains:    CommToolbox File Transfer Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.4
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __FILETRANSFERS__
  21. #define __FILETRANSFERS__
  22.  
  23.  
  24. #ifndef __WINDOWS__
  25. #include <Windows.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <Memory.h>                                            */
  30. /*        #include <MixedMode.h>                                    */
  31. /*    #include <Quickdraw.h>                                        */
  32. /*        #include <QuickdrawText.h>                                */
  33. /*    #include <Events.h>                                            */
  34. /*        #include <OSUtils.h>                                    */
  35. /*    #include <Controls.h>                                        */
  36. /*        #include <Menus.h>                                        */
  37.  
  38. #ifndef __CTBUTILITIES__
  39. #include <CTBUtilities.h>
  40. #endif
  41. /*    #include <Dialogs.h>                                        */
  42. /*        #include <Errors.h>                                        */
  43. /*        #include <TextEdit.h>                                    */
  44. /*    #include <StandardFile.h>                                    */
  45. /*        #include <Files.h>                                        */
  46. /*            #include <Finder.h>                                    */
  47. /*    #include <AppleTalk.h>                                        */
  48.  
  49. #ifndef __CONNECTIONS__
  50. #include <Connections.h>
  51. #endif
  52.  
  53. #ifndef __FILES__
  54. #include <Files.h>
  55. #endif
  56.  
  57. #ifndef __TERMINALS__
  58. #include <Terminals.h>
  59. #endif
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. #if PRAGMA_ALIGN_SUPPORTED
  66. #pragma options align=mac68k
  67. #endif
  68.  
  69. #if PRAGMA_IMPORT_SUPPORTED
  70. #pragma import on
  71. #endif
  72.  
  73.  
  74. enum {
  75. /* current file transfer manager version    */
  76.     curFTVersion                = 2,
  77. /* FTErr    */
  78.     ftGenericError                = -1,
  79.     ftNoErr                        = 0,
  80.     ftRejected                    = 1,
  81.     ftFailed                    = 2,
  82.     ftTimeOut                    = 3,
  83.     ftTooManyRetry                = 4,
  84.     ftNotEnoughDSpace            = 5,
  85.     ftRemoteCancel                = 6,
  86.     ftWrongFormat                = 7,
  87.     ftNoTools                    = 8,
  88.     ftUserCancel                = 9,
  89.     ftNotSupported                = 10
  90. };
  91.  
  92. typedef OSErr FTErr;
  93.  
  94.  
  95. enum {
  96.     ftIsFTMode                    = 1 << 0,
  97.     ftNoMenus                    = 1 << 1,
  98.     ftQuiet                        = 1 << 2,
  99.     ftConfigChanged                = 1 << 4,
  100.     ftSucc                        = 1 << 7
  101. };
  102.  
  103. typedef unsigned long FTFlags;
  104.  
  105.  
  106. enum {
  107.     ftSameCircuit                = 1 << 0,
  108.     ftSendDisable                = 1 << 1,
  109.     ftReceiveDisable            = 1 << 2,
  110.     ftTextOnly                    = 1 << 3,
  111.     ftNoStdFile                    = 1 << 4,
  112.     ftMultipleFileSend            = 1 << 5
  113. };
  114.  
  115. typedef unsigned short FTAttributes;
  116.  
  117.  
  118. enum {
  119.     ftReceiving,
  120.     ftTransmitting,
  121.     ftFullDuplex             /* (16) added ftFullDuplex bit */
  122. };
  123.  
  124. typedef unsigned short FTDirection;
  125.  
  126. /*    application routines type definitions */
  127. typedef struct FTRecord FTRecord, *FTPtr, **FTHandle;
  128.  
  129. typedef pascal long  (*FileTransferDefProcPtr)(TermHandle hTerm, short msg, long p1, long p2, long p3);
  130. typedef pascal OSErr (*FileTransferReadProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  131. typedef pascal OSErr (*FileTransferWriteProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  132. typedef pascal Size  (*FileTransferSendProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags flag);
  133. typedef pascal Size  (*FileTransferReceiveProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags *flag);
  134. typedef pascal OSErr (*FileTransferEnvironsProcPtr)(long refCon, ConnEnvironRec *theEnvirons);
  135. typedef pascal void  (*FileTransferNotificationProcPtr) (FTHandle hFT, const FSSpec* pFSSpec);
  136. typedef pascal void  (*FileTransferChooseIdleProcPtr)(void);
  137.  
  138. #if GENERATINGCFM
  139. typedef UniversalProcPtr FileTransferDefUPP;
  140. typedef UniversalProcPtr FileTransferReadUPP;
  141. typedef UniversalProcPtr FileTransferWriteUPP;
  142. typedef UniversalProcPtr FileTransferSendUPP;
  143. typedef UniversalProcPtr FileTransferReceiveUPP;
  144. typedef UniversalProcPtr FileTransferEnvironsUPP;
  145. typedef UniversalProcPtr FileTransferNotificationUPP;
  146. typedef UniversalProcPtr FileTransferChooseIdleUPP;
  147. #else
  148. typedef FileTransferDefProcPtr FileTransferDefUPP;
  149. typedef FileTransferReadProcPtr FileTransferReadUPP;
  150. typedef FileTransferWriteProcPtr FileTransferWriteUPP;
  151. typedef FileTransferSendProcPtr FileTransferSendUPP;
  152. typedef FileTransferReceiveProcPtr FileTransferReceiveUPP;
  153. typedef FileTransferEnvironsProcPtr FileTransferEnvironsUPP;
  154. typedef FileTransferNotificationProcPtr FileTransferNotificationUPP;
  155. typedef FileTransferChooseIdleProcPtr FileTransferChooseIdleUPP;
  156. #endif
  157.  
  158. struct FTRecord {
  159.     short                            procID;
  160.     FTFlags                            flags;
  161.     FTErr                            errCode;
  162.     long                            refCon;
  163.     long                            userData;
  164.     FileTransferDefUPP                defProc;
  165.     Ptr                                config;
  166.     Ptr                                oldConfig;
  167.     FileTransferEnvironsUPP            environsProc;
  168.     long                            reserved1;
  169.     long                            reserved2;
  170.     Ptr                                ftPrivate;
  171.     FileTransferSendUPP                sendProc;
  172.     FileTransferReceiveUPP            recvProc;
  173.     FileTransferWriteUPP            writeProc;
  174.     FileTransferReadUPP                readProc;
  175.     WindowPtr                        owner;
  176.     FTDirection                        direction;
  177.     SFReply                            theReply;
  178.     long                            writePtr;
  179.     long                            readPtr;
  180.     char                            *theBuf;
  181.     long                            bufSize;
  182.     Str255                            autoRec;
  183.     FTAttributes                    attributes;
  184. };
  185.  
  186. enum {
  187. /* FTReadProc messages */
  188.     ftReadOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  189.     ftReadDataFork                = 1,
  190.     ftReadRsrcFork                = 2,
  191.     ftReadAbort                    = 3,
  192.     ftReadComplete                = 4,
  193.     ftReadSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  194.     ftReadGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  195. /* FTWriteProc messages */
  196.     ftWriteOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  197.     ftWriteDataFork                = 1,
  198.     ftWriteRsrcFork                = 2,
  199.     ftWriteAbort                = 3,
  200.     ftWriteComplete                = 4,
  201.     ftWriteFileInfo                = 5,
  202.     ftWriteSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  203.     ftWriteGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  204. /*    fork flags */
  205.     ftOpenDataFork                = 1,
  206.     ftOpenRsrcFork                = 2
  207. };
  208.  
  209. enum {
  210.     uppFileTransferDefProcInfo = kPascalStackBased
  211.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  212.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  213.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  214.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  215.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  216.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  217.     uppFileTransferReadProcInfo = kPascalStackBased
  218.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  219.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  220.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  221.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  222.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  223.     uppFileTransferWriteProcInfo = kPascalStackBased
  224.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  225.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  226.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  227.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  228.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  229.     uppFileTransferSendProcInfo = kPascalStackBased
  230.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  231.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  232.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  233.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  234.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  235.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags))),
  236.     uppFileTransferReceiveProcInfo = kPascalStackBased
  237.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  238.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  239.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  240.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  241.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  242.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags*))),
  243.     uppFileTransferEnvironsProcInfo = kPascalStackBased
  244.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  245.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  246.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ConnEnvironRec*))),
  247.     uppFileTransferNotificationProcInfo = kPascalStackBased
  248.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FTHandle)))
  249.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FSSpecPtr))),
  250.     uppFileTransferChooseIdleProcInfo = kPascalStackBased
  251. };
  252.  
  253. #if GENERATINGCFM
  254. #define NewFileTransferDefProc(userRoutine)        \
  255.         (FileTransferDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferDefProcInfo, GetCurrentArchitecture())
  256. #define NewFileTransferReadProc(userRoutine)        \
  257.         (FileTransferReadUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReadProcInfo, GetCurrentArchitecture())
  258. #define NewFileTransferWriteProc(userRoutine)        \
  259.         (FileTransferWriteUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferWriteProcInfo, GetCurrentArchitecture())
  260. #define NewFileTransferSendProc(userRoutine)        \
  261.         (FileTransferSendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferSendProcInfo, GetCurrentArchitecture())
  262. #define NewFileTransferReceiveProc(userRoutine)        \
  263.         (FileTransferReceiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, GetCurrentArchitecture())
  264. #define NewFileTransferEnvironsProc(userRoutine)        \
  265.         (FileTransferEnvironsUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, GetCurrentArchitecture())
  266. #define NewFileTransferNotificationProc(userRoutine)        \
  267.         (FileTransferNotificationUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, GetCurrentArchitecture())
  268. #define NewFileTransferChooseIdleProc(userRoutine)        \
  269.         (FileTransferChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo, GetCurrentArchitecture())
  270. #else
  271. #define NewFileTransferDefProc(userRoutine)        \
  272.         ((FileTransferDefUPP) (userRoutine))
  273. #define NewFileTransferReadProc(userRoutine)        \
  274.         ((FileTransferReadUPP) (userRoutine))
  275. #define NewFileTransferWriteProc(userRoutine)        \
  276.         ((FileTransferWriteUPP) (userRoutine))
  277. #define NewFileTransferSendProc(userRoutine)        \
  278.         ((FileTransferSendUPP) (userRoutine))
  279. #define NewFileTransferReceiveProc(userRoutine)        \
  280.         ((FileTransferReceiveUPP) (userRoutine))
  281. #define NewFileTransferEnvironsProc(userRoutine)        \
  282.         ((FileTransferEnvironsUPP) (userRoutine))
  283. #define NewFileTransferNotificationProc(userRoutine)        \
  284.         ((FileTransferNotificationUPP) (userRoutine))
  285. #define NewFileTransferChooseIdleProc(userRoutine)        \
  286.         ((FileTransferChooseIdleUPP) (userRoutine))
  287. #endif
  288.  
  289. #if GENERATINGCFM
  290. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  291.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferDefProcInfo, (hTerm), (msg), (p1), (p2), (p3))
  292. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  293.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReadProcInfo, (count), (pData), (refCon), (fileMsg))
  294. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  295.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferWriteProcInfo, (count), (pData), (refCon), (fileMsg))
  296. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  297.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferSendProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  298. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  299.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  300. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  301.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, (refCon), (theEnvirons))
  302. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  303.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, (hFT), (pFSSpec))
  304. #define CallFileTransferChooseIdleProc(userRoutine)        \
  305.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo)
  306. #else
  307. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  308.         (*(userRoutine))((hTerm), (msg), (p1), (p2), (p3))
  309. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  310.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  311. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  312.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  313. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  314.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  315. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  316.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  317. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  318.         (*(userRoutine))((refCon), (theEnvirons))
  319. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  320.         (*(userRoutine))((hFT), (pFSSpec))
  321. #define CallFileTransferChooseIdleProc(userRoutine)        \
  322.         (*(userRoutine))()
  323. #endif
  324.  
  325. extern pascal FTErr InitFT(void);
  326. extern pascal Handle FTGetVersion(FTHandle hFT);
  327. extern pascal short FTGetFTVersion(void);
  328. extern pascal FTHandle FTNew(short procID, FTFlags flags, FileTransferSendUPP sendProc, FileTransferReceiveUPP recvProc, FileTransferReadUPP readProc, FileTransferWriteUPP writeProc, FileTransferEnvironsUPP environsProc, WindowPtr owner, long refCon, long userData);
  329. extern pascal void FTDispose(FTHandle hFT);
  330. extern pascal FTErr FTStart(FTHandle hFT, FTDirection direction, const SFReply *fileInfo);
  331. extern pascal FTErr FTAbort(FTHandle hFT);
  332. extern pascal FTErr FTSend(FTHandle hFT, short numFiles, FSSpecArrayPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  333. extern pascal FTErr FTReceive(FTHandle hFT, FSSpecPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  334. extern pascal void FTExec(FTHandle hFT);
  335. extern pascal void FTActivate(FTHandle hFT, Boolean activate);
  336. extern pascal void FTResume(FTHandle hFT, Boolean resume);
  337. extern pascal Boolean FTMenu(FTHandle hFT, short menuID, short item);
  338. extern pascal short FTChoose(FTHandle *hFT, Point where, FileTransferChooseIdleUPP idleProc);
  339. extern pascal void FTEvent(FTHandle hFT, const EventRecord *theEvent);
  340. extern pascal Boolean FTValidate(FTHandle hFT);
  341. extern pascal void FTDefault(Ptr *theConfig, short procID, Boolean allocate);
  342. extern pascal Handle FTSetupPreflight(short procID, long *magicCookie);
  343. extern pascal void FTSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  344. extern pascal Boolean FTSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  345. extern pascal void FTSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  346. extern pascal void FTSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  347. extern pascal void FTSetupPostflight(short procID);
  348. extern pascal Ptr FTGetConfig(FTHandle hFT);
  349. extern pascal short FTSetConfig(FTHandle hFT, const void *thePtr);
  350. pascal FTErr  FTIntlToEnglish(FTHandle hFT,const void *inputPtr,Ptr *outputPtr, short language);
  351. pascal FTErr  FTEnglishToIntl(FTHandle hFT,const void *inputPtr,Ptr *outputPtr, short language);
  352. extern pascal void FTGetToolName(short procID, Str255 name);
  353. extern pascal short FTGetProcID(ConstStr255Param name);
  354. extern pascal void FTSetRefCon(FTHandle hFT, long refCon);
  355. extern pascal long FTGetRefCon(FTHandle hFT);
  356. extern pascal void FTSetUserData(FTHandle hFT, long userData);
  357. extern pascal long FTGetUserData(FTHandle hFT);
  358. extern pascal void FTGetErrorString(FTHandle hFT, short id, Str255 errMsg);
  359.  
  360. #if PRAGMA_IMPORT_SUPPORTED
  361. #pragma import off
  362. #endif
  363.  
  364. #if PRAGMA_ALIGN_SUPPORTED
  365. #pragma options align=reset
  366. #endif
  367.  
  368. #ifdef __cplusplus
  369. }
  370. #endif
  371.  
  372. #endif /* __FILETRANSFERS__ */
  373.